/**
 * 隐患上报 编辑页
 *
 * 作者 wanghw
 * 日期 2024-08-20 09:23:04
 */
layui.use(['jquery','febs', 'form', 'validate', 'fileUpload', 'autocomplete','commonJS'], function () {
    var $ = layui.$,
        febs = layui.febs,
        layer = layui.layer,
        form = layui.form,
        fileUpload = layui.fileUpload,
        $view = $('#hazardReportSort-delete'),
        commonJS = layui.commonJS,
        validate = layui.validate;

    form.verify(validate);
    form.render();
    initFormValue();


    function initImg() {
        var fileUploadDiv = fileUpload.render({
            elem: '#fileUpload',
            url: '',
            type: 0,//0-图片，1-视频，2-其他
            maxNum:5,
            defaultData: hazardReport && hazardReport.fileList ? hazardReport.fileList:[],
            isDetail:true,
            done: function (res) {
            },
        });

    }


    function initFormValue() {
        initImg();
    }

    form.on('submit(hazardReportSort-deleted-form-submit)', function (data) {
        addOrUpdate(data.field);
        return false;
    });

    function addOrUpdate(data) {
        febs.modal.confirm('删除隐患信息', '确定删除信息？', function () {
            febs.postArray(ctx + 'hazardReportSort/delete', data, function () {
                layer.closeAll();
                febs.alert.success('删除成功');
                $('#febs-hazardReportSort').find('#query').trigger('click');
            });
        });

    }


    form.on('radio(auditStatus)',function (obj){
        if(obj.value == '6'){
            //审核
            $('#auditInfo').removeClass('febs-hide');
            $('#auditRebackInfo').addClass('febs-hide');
            $view.find('textarea[name="auditReason"]').attr("lay-verify","");
            $view.find('textarea[name="auditRemark"]').attr("lay-verify","required")
        }else {
            //审核退回
            $('#auditInfo').addClass('febs-hide');
            $('#auditRebackInfo').removeClass('febs-hide');
            $view.find('textarea[name="auditReason"]').attr("lay-verify","required")
            $view.find('textarea[name="auditRemark"]').attr("lay-verify","")
        }

    })


});